package com.yfjin.gl.soul;

import android.content.Context;
import android.opengl.GLES20;

import com.yfjin.gl.R;
import com.yfjin.gl.filter.AbstractFboFilter;

public class SoulFilter extends AbstractFboFilter {

    private int mixtureAddress = 0;
    private int scalPercentAddress = 0;

    float scal = 0.0f;
    float mix = 0.0f;

    public SoulFilter(Context context) {
        super(context, R.raw.base_vert, R.raw.soul_frag);
        scalPercentAddress = GLES20.glGetUniformLocation(program, "scalePercent");
        mixtureAddress = GLES20.glGetUniformLocation(program, "mixturePercent");
    }

    @Override
    protected void beforeDraw() {
        //+1f 意思是放大两倍
        GLES20.glUniform1f(scalPercentAddress, scal + 1f);
        scal += 0.05f;
        if (scal >= 1f) {
            scal = 0;

        }

        GLES20.glUniform1f(mixtureAddress, 1f-mix);
        mix += 0.05f;
        if (mix>=1f){
            mix = 0;
        }
    }

    @Override
    public int onDraw(int texture) {
        super.onDraw(texture);
        return frameTextures[0];
    }
}
